kivy ScreenManager showing error during running of code

by: sanjaykmandi, 7 years ago


from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager,Screen,FadeTransition

class MainScreen(Screen):
   pass

class AnotherScreen(Screen):
   pass

class ScreenManagement(ScreenManager):
   pass

presentation=Builder.load_file("main.kv")

class MainApp(App):
    def build(self):
        return presentation()

MainApp().run()
-----------------------------------------------------------
ScreenManagement:
   transition:FadeTransition()
   MainScreen:
   AnotherScreen:

<MainScreen>:
   name:'main'
   Button:
      on_release:app.root.current = 'other'
      text:'Another Screen'
      font_size:50
<AnotherScreen>:
   name:'other'
  
   Button:
      on_release:app.root.current='main'
      text:'back to the home screen'
      font_size:50
-------------------------------------------
whenever i am trying to run this code showing below error

desertfox@desertfox-desktop:~$ python main2.py
[INFO   ] [Logger      ] Record log in /home/desertfox/.kivy/logs/kivy_17-08-06_55.txt
[INFO   ] [Kivy        ] v1.9.1
[INFO   ] [Python      ] v2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609]
[INFO   ] [Factory     ] 179 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO   ] [GL          ] OpenGL version <2.1 Mesa 11.2.0>
[INFO   ] [GL          ] OpenGL vendor <Intel Open Source Technology Center>
[INFO   ] [GL          ] OpenGL renderer <Mesa DRI Intel(R) G41 >
[INFO   ] [GL          ] OpenGL parsed version: 2, 1
[INFO   ] [GL          ] Shading version <1.20>
[INFO   ] [GL          ] Texture max size <8192>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Text        ] Provider: sdl2
Traceback (most recent call last):
   File "main2.py", line 14, in <module>
     presentation=Builder.load_file("main.kv")
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1842, in load_file
     return self.load_string(data, **kwargs)
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1921, in load_string
     self._apply_rule(widget, parser.root, parser.root)
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 2130, in _apply_rule
     e), cause=tb)
kivy.lang.BuilderException: Parser: File "main.kv", line 2:
...
       1:ScreenManagement:
>>    2:   transition:FadeTransition()
       3:   MainScreen:
       4:   AnotherScreen:
...
BuilderException: Parser: File "main.kv", line 2:
...
       1:ScreenManagement:
>>    2:   transition:FadeTransition()
       3:   MainScreen:
       4:   AnotherScreen:
...
NameError: name 'FadeTransition' is not defined
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1742, in create_handler
     return eval(value, idmap), bound_list
   File "main.kv", line 2, in <module>
     transition:FadeTransition()

   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 2115, in _apply_rule
     rctx['ids'])
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1747, in create_handler
     cause=tb)
anyone help me?



You must be logged in to post. Please login or register an account.